package com.fuyao.cloud.admin.bulletin.vo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @author lyhills
 * @Description
 * @date 2023/7/4 11:13
 * @Version 1.0
 */
@Data
public class BulletinVO {
    private static final long serialVersionUID = 1L;

    @TableId
    @ApiModelProperty("主键Id")
    private Long id;

    @ApiModelProperty("unid")
    private String unid;

    @ApiModelProperty("单位、部门ID")
    private Long deptId;

    @ApiModelProperty("部门全名称")
    private String deptFullname;

    @ApiModelProperty("创建人")
    private String createBy;

    @ApiModelProperty("创建人ID")
    private Long createId;

    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

    @ApiModelProperty("修改人")
    private String updateBy;

    @ApiModelProperty("修改时间")
    private LocalDateTime updateTime;

    /**
     * 类型编码
     */
    @ApiModelProperty(value = "类型编码")
    private String typeCode;

    /**
     * 类型名称
     */
    @ApiModelProperty(value = "类型名称")
    private String typeName;

    /**
     * 状态： 0：草稿，1：已发布
     */
    @ApiModelProperty(value = "状态： 0：草稿，1：已发布")
    private String status;

    /**
     * 主题
     */
    @ApiModelProperty(value = "主题")
    private String subject;

    /**
     * 内容
     */
    @ApiModelProperty(value = "内容")
    private String content;

    /**
     * 发布时间
     */
    @ApiModelProperty(value = "发布时间")
    private LocalDateTime pushTime;

    /**
     * 是否发布至首页：N:否，Y:是
     */
    @ApiModelProperty(value = "是否发布至首页：N:否，Y:是")
    private String pushFirstPage;

    /**
     * 发布类型：{ALL:全部，USER:指定用户: GROUP:指定岗位,UNIT:单位}
     */
    @ApiModelProperty(value = "发布类型：{ALL:全部，USER:指定用户: GROUP:指定岗位,UNIT:单位}")
    private String pushType;

    /**
     * 是否发布OA: N:否，Y:是
     */
    @ApiModelProperty(value = "是否发布OA: N:否，Y:是")
    private String mobileoa;

    /**
     * CRON表达式
     */
    @ApiModelProperty(value = "CRON表达式")
    private String cronExpression;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    private String remarks;

    @ApiModelProperty(value = "发布用户ID")
    private Long pushUserId;

    @ApiModelProperty(value = "发布用户名称")
    private String pushUserName;

    @ApiModelProperty(value = "发布用户部门ID")
    private Long pushUserDeptId;

    @ApiModelProperty(value = "发布用户部门名称")
    private String pushUserDeptFullname;

    @ApiModelProperty(value = "当前用户浏览次数")
    private long curUserReadCount;

    // 获取部门名称
    public String getPushUserOuName() {
        if (StrUtil.isEmpty(this.pushUserDeptFullname)) {
            return "";
        } else {
            return this.pushUserDeptFullname.contains(".") ? this.pushUserDeptFullname.substring(this.pushUserDeptFullname.indexOf(".") + 1) : this.pushUserDeptFullname;
        }
    }
}
